#pragma once
#include "reactor.hpp"
#include "socket.hpp"
#include "Util.hpp"
#include "service.hpp"


int Accepter(Event* ev)
{
    while(true)
    {
        int sock = Sock::Accept(ev->sock);
        if(sock < 0)
        {
            std::cout << "Accept Done!" << std::endl;
            break;
        }
        std::cout << "有新的连接到来了 " << sock << std::endl;
        SetNonBlock(sock);
        Event* evl = new Event();
        evl->R = ev->R;
        evl->sock = sock;

        evl->RegisterEvent(recver, sender, errorer);
        ev->R->InsertEvent(evl, EPOLLIN | EPOLLET);
    }

    return -1;
}